// eslint-disable-next-line
import { UserLayout, BasicLayout } from '@/layouts'

const RouteView = {
  name: 'RouteView',
  render: (h) => h('router-view'),
}

export const asyncRouterMap = [
  {
    path: '/',
    component: BasicLayout,
    meta: {
      title: '首页',
      permission: ['admin'],
    },
    redirect: '/dashboard/workplace',
    children: [
      // dashboard
      {
        path: '/dashboard',
        redirect: '/dashboard/workplace',
        component: RouteView,
        meta: {
          title: 'dashboard',
          keepAlive: true,
          icon: 'home',
          permission: ['admin'],
        },
        children: [
          {
            path: '/dashboard/workplace',
            name: 'Dashboard',
            component: () => import('@/views/dashboard/Workplace'),
            meta: {
              title: '首页',
              keepAlive: false,
              permission: ['admin'],
            },
          },
        ],
      },
      // user manage
      {
        path: '/usermanage',
        name: 'UserManage',
        component: RouteView,
        redirect: '/usermanage/list',
        meta: {
          title: '订单管理',
          icon: 'user',
          permission: ['admin'],
        },
        children: [
          {
            path: '/usermanage/list',
            name: 'UserManageList',
            // hideChildrenInMenu: true, // 强制显示 MenuItem 而不是 SubMenu
            component: () => import('@/views/usermanage/index.vue'),
            meta: {
              title: '订单',
              keepAlive: true,
              permission: ['admin'],
            },
          },
        ],
      },
      // Exception
      {
        path: '/exception',
        name: 'exception',
        component: RouteView,
        redirect: '/exception/403',
        meta: {
          title: 'menu.exception',
          icon: 'warning',
          permission: ['exception'],
        },
        children: [
          {
            path: '/exception/403',
            name: 'Exception403',
            component: () => import(/* webpackChunkName: "fail" */ '@/views/exception/403'),
            meta: {
              title: 'menu.exception.not-permission',
              permission: ['exception'],
            },
          },
          {
            path: '/exception/404',
            name: 'Exception404',
            component: () => import(/* webpackChunkName: "fail" */ '@/views/exception/404'),
            meta: {
              title: 'menu.exception.not-find',
              permission: ['exception'],
            },
          },
          {
            path: '/exception/500',
            name: 'Exception500',
            component: () => import(/* webpackChunkName: "fail" */ '@/views/exception/500'),
            meta: {
              title: 'menu.exception.server-error',
              permission: ['exception'],
            },
          },
        ],
      },
    ],
  },
  {
    path: '*',
    redirect: '/404',
    hidden: true,
  },
]

/**
 * 基础路由
 * @type { *[] }
 */
export const constantRouterMap1 = [
  {
    path: '/user',
    component: UserLayout,
    redirect: '/user/login',
    hidden: true,
    children: [
      {
        path: 'login',
        name: 'login',
        component: () => import(/* webpackChunkName: "user" */ '@/views/user/Login'),
      },
      {
        path: 'register',
        name: 'register',
        component: () => import(/* webpackChunkName: "user" */ '@/views/user/Register'),
      },
      {
        path: 'register-result',
        name: 'registerResult',
        component: () => import(/* webpackChunkName: "user" */ '@/views/user/RegisterResult'),
      },
      {
        path: 'recover',
        name: 'recover',
        component: undefined,
      },
    ],
  },
  {
    path: '/404',
    component: () => import(/* webpackChunkName: "fail" */ '@/views/exception/404'),
  },
]
export const constantRouterMap = [...asyncRouterMap, ...constantRouterMap1]
